#ifndef MYSQL_CONNECT_POOL_H
#define MYSQL_CONNECT_POOL_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <pthread.h>

#include "mysql-connect.h"
#include "mysql-connect-queue.h"
#include "mysql-connect-factory.h"

typedef struct MysqlConnectPool MysqlConnectPool;

enum MysqlConnectPoolState {    // 连接池的状态
    Running,                    // 运行中: 连接池正常工作
    Shutdown,                   // 关闭: 连接池关闭;
};

// 创建 MYSQL 连接池
MysqlConnectPool *
createMysqlConnectPool(char *ip, char *user, char *password, char *database, int port, int timeout_time,
                       int keep_alive_time, int core_connect_number, int max_connect_number);

// 销毁 MYSQL 连接池
void destroyMysqlConnectPool(MysqlConnectPool *pool);

// 获取 MYSQL 连接
MysqlConnect *getConnect(MysqlConnectPool *pool);

// 释放 MYSQL 连接
void freeConnect(MysqlConnectPool *pool, MysqlConnect *connect);

#endif // MYSQL_CONNECT_POLL_H